/**
 * 系统用户
 * @author rxliuli
 */
const sysLoginApi = new class SysLoginApi {
    using(url) {
        return '/system' + url
    }

    async login(sysUser) {
        return (await rxajax.postJson(this.using('/login'), sysUser)).data
    }

    async logout() {
        return (await rxajax.postJson(this.using('/logout'))).data
    }

    async getCode(sysUser) {
        return (await rxajax.postJson(this.using('/get-code'), sysUser)
        ).data
    }

    async getVerify() {
        return (await rxajax.get(this.using('/get-verify'))).data.data
    }

    currentUser = rx.CacheUtil.onceOfSameParam(async () => (await rxajax.get(this.using('/current-user'))).data.data, {
        identity: 'sysLoginApi.currentUser',
    })
}()